added error check for stage3