Finished output to bin function. Maybe it works?