refactored fix based on feedback