Changing so that it returns out of the function