Rewrite wrap function check to single conditional