fixed bug in IsDatabaseRecordExist function