more refactoring. ex3 still needs working