Implemented bin counting