Correct error handling
added header and footer documentation