added comments, finished third part