backend logic reorganization