Fix bug where resource was added multiple times