Refactor in accordance with comments