Code refactoring - stage 1