Change to error handling
Should make it easier to read