Rewrite to support any material