Added ejs for rendering and code refactor