refactoring

refactoring the database methods into a dal