Refactored a little bit.