modified the coordinate handling to account for element and page offsets