Rreduce code duplication