removing repetition in fmincg