Refine codes and improve user experience