fixed loop erro - missing end