Improving the code and the comments