put bin function direct after form the pairs to save memory and computational time