add condition, loop and error handling