improved rec_constell.m function