loop removed and corrections made