improved bin implementation