implement best fit feature