updated coded optimized for n = 40 and m = 48