Avoiding somme serious code duplication