Refactor importing code