fix iresourceonly issue, optimize code