changed function argument order, simplified routine
simplified constant M/J lost part
turn on J upper bound condition by default