Refactor to add xoptions