fixed some bugs
gp optimization