replacing more uses of read function with array-style slicing