Finally fixed the registration bug