Rewrite with libraries