moved error function