basic error handling added