improved options function