modified some code structure