Now with database and barycentre algorithm with sigma calculation