added user loop code