Added and merged statistical function