changed compare condition to using slope instead of vertical diff