working main with centroiding