Implementing logic for average fitness calculation