Improve code readability and add some comments