error handling added