1. further improve the code