improve checks and error responses
formatting changes