extract middleware steps from Utils