modified some main code