optimise math.abs and math.ceil