implemented particle swarm and fixed some bugs