Updated code

Tried to solve the existing issues