last_stage :: Int -> Double -> Int -> Int -> Int -> Point -> Int -> Point -> [Point] -> [Point]
last_stage i epsi count new_count pos start_pt wpos pt dstContours
        | i == count || new_count <= 2 = dstContours
        | otherwise                    = last_stage (l_s_f_fst !! 0) epsi count (l_s_f_fst !! 1) (addSafePos (l_s_f_fst !! 3) count) (l_s_f_trd !! 0) (l_s_f_fst !! 2) (l_s_f_trd !! 1) l_s_f_snd
        where
                end_pt                   = readDstPt dstContours pos
                dx                       = dxFunc end_pt start_pt
                dy                       = dyFunc end_pt start_pt
                dist                     = abs (((fst pt) - (fst start_pt)) * dy - ((snd pt) - (snd start_pt)) * dx)
                successive_inner_product = (((fst pt) - (fst start_pt)) * ((fst end_pt) - (fst pt)) + ((snd pt) - (snd start_pt)) * ((snd end_pt) - (snd pt)))
                l_s_f                    = last_stage_decision (fromIntegral dist) successive_inner_product epsi dx dy i count wpos pos new_count start_pt end_pt pt dstContours
                l_s_f_fst                = myfst l_s_f
                l_s_f_snd                = mysnd l_s_f
                l_s_f_trd                = trd l_s_f 
last_stage :: Int -> Double -> Int -> Int -> Int -> Point -> Int -> Point -> [Point] -> [Point]
last_stage i epsi count new_count pos start_pt wpos pt dstContours
        | i == count || new_count <= 2 = dstContours
        | otherwise                    = last_stage (l_s_f_fst !! 0) epsi count (l_s_f_fst !! 1) (addSafePos (l_s_f_fst !! 3) count) (l_s_f_trd !! 0) (l_s_f_fst !! 2) (l_s_f_trd !! 1) l_s_f_snd
        where
                end_pt                   = readDstPt dstContours pos
                dx                       = dxFunc end_pt start_pt
                dy                       = dyFunc end_pt start_pt
                dist                     = abs (((fst pt) - (fst start_pt)) * dy - ((snd pt) - (snd start_pt)) * dx)
                successive_inner_product = (((fst pt) - (fst start_pt)) * ((fst end_pt) - (fst pt)) + ((snd pt) - (snd start_pt)) * ((snd end_pt) - (snd pt)))
                l_s_f                    = last_stage_decision (fromIntegral dist) successive_inner_product epsi dx dy i count wpos pos new_count start_pt end_pt pt dstContours
                l_s_f_fst                = myfst l_s_f
                l_s_f_snd                = mysnd l_s_f
                l_s_f_trd                = trd l_s_f 
last_stage i epsi count new_count pos start_pt wpos pt dstContours
        | i == count || new_count <= 2 = dstContours
        | otherwise                    = last_stage (l_s_f_fst !! 0) epsi count (l_s_f_fst !! 1) (addSafePos (l_s_f_fst !! 3) count) (l_s_f_trd !! 0) (l_s_f_fst !! 2) (l_s_f_trd !! 1) l_s_f_snd
        where
                end_pt                   = readDstPt dstContours pos
                dx                       = dxFunc end_pt start_pt
                dy                       = dyFunc end_pt start_pt
                dist                     = abs (((fst pt) - (fst start_pt)) * dy - ((snd pt) - (snd start_pt)) * dx)
                successive_inner_product = (((fst pt) - (fst start_pt)) * ((fst end_pt) - (fst pt)) + ((snd pt) - (snd start_pt)) * ((snd end_pt) - (snd pt)))
                l_s_f                    = last_stage_decision (fromIntegral dist) successive_inner_product epsi dx dy i count wpos pos new_count start_pt end_pt pt dstContours
                l_s_f_fst                = myfst l_s_f
                l_s_f_snd                = mysnd l_s_f
                l_s_f_trd                = trd l_s_f 