modified the mkmod bash function