hw6 nearest improved, but with bug