Updated code for registration and subscription