implementing reading in Swift