added comments, changed some parameter names