small improvement

avoid multiple writes to the same location