added loop routine