created function for_do() to handle for-do loops