Refactor common  backend functions