working version with resource parsing