fix withResource method