refactored and added helpers