Fixed sign of a variable in depth calculation