Implement loops in execute_command