registration function and bug fix