more stats
Making calculations into function, such that can be used in an apply loop