refact code in unique path problem