refactor in read_api