working pso algorithm