Feature/refactor logic to backend