Adding more comments and better organizing functions