a bit more refactor