code input rewritten