corrected bin() routine