Added some comments + refactor