Peter refactored a bit