solved some database access bugs