add toBinaryString algorithm