Reduce similar code.