fixed the abs() bug, by changing it to labs()