Refactored Client code, Added database access to client