[FIX] write() : Correction to avoid overwriting of variable ids and optimization...