refactored, implimenting repository pattern