refactoring following review comments