changed to accept a reader