refactor cfg reading into function