Extract prompt logic