address pr comments. refactoring