Corrected wrong variable names for database access