refactored version with better naming