Added Required libraries and changes the code