Fixed up the code structure