fixing dom reading problems js