initialising error variable so final status is correct