Refactor the launch process in the api