refactor a bit.