reorder steps to avoid some warnings