fixed looping issues