refactored a bit for concision