refactor and build options functionality