a try to workaround the return statement limitation
add decreases statement to verify termination of loop