code cleanup
refactored database access to own class