Made code more DRY