refactor to support options