Added logic to frontend and most of the bit logic to the backend.