Improved the code structure here.