Removed duplicated comparison

Compared a variable before calling a function and again inside the
function