Refactored a liitle more.