improved xMin/xMax implementation based on markbakker78/rickshaw@16bae00fcb