Moved search logic to backend.js