Reduced code duplication to improve CodeClimate score.