move code snippet closer to its use