First refactoring - finished