Code refactoring - update with comments