modified the api handler