Fixing if logic a bit