simplified to one iteration. thanks soucy