update entities with update/create timestamp, optimize code