registration logic, doesn't work for weird and mysterious reasons