rewritten code