Basic error handling added