Reduce duplicate code
Reduce duplicate code