implemented ifElse