Cleaner engine

Cleaner and easy to understand engine.rb