simplified some codes