adding loop functionality
adding loop functionality
various improvements