Commiting engine file,  this code still needs to be refactored