refactoring scotty code