implemented version 2 and fixed some comments