adding type to resource as a key that holds the type of the resource.
minor refactoring