Update engine.R

I messed up by using ifelse() when I should have used if then else.