Updated replace method to use delegated classes