Refactoring registration buttons listener and fixed some bugs