Fix bad if and var ref