added loop completion handler