Refactor read-related functions