Implemented fitness function