started on refactoring, INCOMPLETE