refactor, and start testing