check bug and start refactoring