Update engine.R

I messed up by using ifelse() when I should have used if then else.
Merge pull request #563 from NickSalkowski/master

My mistake!: Needs if then else, not ifelse -- otherwise only the first line of code is written.