FInally solved it by using lots of local variables with absolute value.