refactor and complete num args test and valid option check