if statement checking of each element, functional but not solving correctly, need debugging