handling resources correctly