moving logic to backend