Code refactoring as per review comments