modified some codes and runs well