made the code more DRY, last commit of tonight