Added few comments and fixed the end of functions