Improve the code. (@ujifgc's approach)