added some abs() that were needed