updated loop and handlers