refactored backend