better error handling for matlab