I was too tired to notice it, but lower x was higher than upper x. For calculating extent I should have taken abs: