Started on refactoring