added method to calculate stats