added functions to engine,js and models.js