added comments, refacoring: introduced some methods