addressing pr comments, refactoring