Improve registration logic