added slope calculation