added extra comments and extracted method. dry son