changed code structure for auto step.