added error reporting and variable getter