changed error message and passing headers