resolving some issue with error handling