Implemented toBinary function