added loop logic