organizing auto mode code