function for calculating element areas