Added some comments and renamed the buffer variable