rewrites if
some fixes