refactored sql queries and decoupled dataAccess from the db