Return value set in the loop. Not the most efficient way. Will be fixed
later.