Rewrite from original code