change implementation of read functions to read binary