fix span calculation