update DOM once, instead of thrice