Fixed bug in finding closest object.