get closest bin function