ChatGPT - Write dispatch function