Cleaner implementation with loop