add debug statements and errors