some basic error handling added