Update Engine.php

Write some logic