Fixed some code structure