please use std::abs here and other places