adjust code order to avoid user onchange error