fixing error cases