Rewrite for general case