Fixing bug in database field return