added scope control to if and ifelse