nicer loop and a fix for removal bug