use for loop and improved error message
0.2.0