Removing replicated code