began refactoring codes