refactored a little.