some re-factoring