fixing issue with broken loop