Made more DRY based on code review