added changes in to code to make it work