Code refactor