Moved check to prevent php notice