updated version
improved getOpArg to simplify code