updated rendering logic after document change