refactor how the selectbox state is stored for the selectbox