added tests and reworked the do function