refactored: removed double loop