Sunny's code added with some required changes