It looks like this first section of code is duplicated between the resources, maybe it would make sense to encapsulate it into a method.