Added handling 500 and 404 errors (404 still WIP)