user registration added, minor refactoring