Updated to reduce duplicate code per peer review