fixed a bug in centroiding