Migrates logic for /workflows handler