refactoring done, I think