Adding more comments, improved the structure