refactoring. Addressed pr comments