Changed variable name and moved the check to the function itself