refactor for api to fetch from json files