debugging pull function, some bugs fixed