Upgraded the code