improve errorhandling for register