refactoring a bit.