updated to match chlevelset.m