Fix for issue #12, also match one input option and less code duplication