Customizing Latest Post Pagination

Well I dug into the function I wrote a bit more and realize the flexibility of the customization I had. So I was able to achieve the above by writing the php this way:

if (!function_exists('pagination')){
    function pagination($pages="", $range = 2){  
         $showitems = ($range * 2)+1;  

         global $paged;
         if(empty($paged)) $paged = 1;

         if($pages == ''){
            global $wp_query;
            $pages = $wp_query->max_num_pages;
            if(!$pages){
                $pages = 1;
            }
         }
         if(1 != $pages){
            echo '<ul>';
            //The Below Line of Code Takes effect if there are more than 5 pages of posts and the code renders a single left arrow "<"
            //if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo '<li><a href="'.get_pagenum_link(1).'" class="tbutton"><span>&laquo;</span></a></li>';
            //The Below Line of Code Takes effect if there are more than 5 pages of posts and the code renders a double left arrow "<<"
            //if($paged > 1 && $showitems < $pages) echo '<li><a href="'.get_pagenum_link($paged - 1).'"><span>&lsaquo;</span></a></li>';
            for ($i=1; $i <= $pages; $i++){
                 if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems )){
                    echo ($paged == $i)? '<li><span class="deactive">'.$i.'</span></li>':'<li><a href="'.get_pagenum_link($i).'" class="tbutton">'.$i.'</a></li>';
                 }
             }
             //The Below Line of Code Takes effect if there are more than 5 pages of posts and the code renders a single right arrow ">"
             //if ($paged < $pages && $showitems < $pages) echo '<li><a href="'.get_pagenum_link($paged + 1).'">&rsaquo;</a></li>';  
             //The Below Line of Code Takes effect if there are more than 5 pages of posts and the code can render a double right arrow ">>" with the html encode of "&raquo;"
             //However instead the code is rendering three dots "..." and the last page number 
             if ($paged < $pages-1 &&  $paged+$range-1 < $pages && $showitems < $pages) echo '<li><li><span class="deactive">...</span></li><a href="'.get_pagenum_link($pages).'" class="tbutton">'.$pages.'</a></li>';
             echo '</ul>';
        }
    }
}

I also added comments. I got this function from HOW TO BUILD A WORDPRESS POST PAGINATION WITHOUT PLUGIN