macro for defining optimal cut