Changed the code structure