refactoring of night coding