Added error handling to the cube