minor refactor, better testing