refactoring to support additional backends