implement maximum deviation in js