Changed horizontal seam function to improve performance.