tidied up logic of NC slope func