diff --git a/Main.hs b/Main.hs
--- a/Main.hs
+++ b/Main.hs
@@ -5,3 +5,5 @@
 
 main :: IO ()
 main = villefort def 
+  
+
diff --git a/README.md b/README.md
--- a/README.md
+++ b/README.md
@@ -1,9 +1,9 @@
 # Villefort
 Villefort is a time managment system written in Haskell.
 
-## Version 1.2.1
-- generally cleaned up code base
-- made daily into the IO monad so it matches the weekly tasks
+## Version 1.2.2
+- Rewrote the weekly sorting by category algorithm so that it actually workds
+- Fix weekly page error.
 
 [default config](https://github.com/Chrisr850/Villefort/blob/master/src/Villefort/Config.hs)
 
@@ -85,23 +85,23 @@
 You should now see different versions of Villefort
 
 Villefort-0.1.1.0/
-
+```
     |-- data/
     |   |-- date
     |   |-- day
     |   |-- todo.db
     |-- templates/
     |-- js.js
-
+```
 Villefort-0.1.1.1/
-
+```
 	|-- data/
 	|   |-- date
 	|   |-- day
 	|   |-- todo.db
 	|-- templates/
 	|-- js.js
-
+```
 Just copy the data/todo.db from the old version into data/todo.db of the new version.
 Then remember to rebuild Villefort if you have a custom build.
  
diff --git a/Villefort.cabal b/Villefort.cabal
--- a/Villefort.cabal
+++ b/Villefort.cabal
@@ -1,5 +1,5 @@
 name:                Villefort
-version:             0.1.2.1
+version:             0.1.2.2
 synopsis: Villefort is a task manager and time tracker written in haskell.
 description: Villefort is a browser based time tracker.
 homepage:            https://github.com/Chrisr850/Villefort#readme
diff --git a/data/todo.db b/data/todo.db
Binary files a/data/todo.db and b/data/todo.db differ
diff --git a/src/Villefort/Daily.hs b/src/Villefort/Daily.hs
--- a/src/Villefort/Daily.hs
+++ b/src/Villefort/Daily.hs
@@ -31,36 +31,48 @@
   where (_,_,week) =  toWeekDate day
         lookup =["","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]
         
-st :: (MonadReader VConfig m, MonadIO m) => m [[String]]
-st = do
+getPrevWeek :: (MonadReader VConfig m, MonadIO m) => m [[String]]
+getPrevWeek = do
   z <- liftIO $  getDatesOfPrevWeek
   t z
   where t  = (\x -> getSubWeek (show $ x !! 0) (show $ x !! 1))
 
-p :: (MonadReader VConfig m, MonadIO m) => m [[String]]
-p = do
+getThisWeek :: (MonadReader VConfig m, MonadIO m) => m [[String]]
+getThisWeek = do
   z <- liftIO $ getDatesOfThisWeek
   t z
   where t  = (\x -> getSubWeek (show $ x !! 0) (show $ x !! 1))
 
 genTabs :: (MonadReader VConfig m, MonadIO m) => m String
 genTabs = do
-  z <- p
-  t <- st
-  f <- liftIO $ getDatesOfPrevWeek
-  n <- liftIO $ getDatesOfThisWeek
-  let q =  sortBy ( compare  `on` head) $ z ++ t
-  return $ makeTable ["Subject","Last week"++ show f,"This week" ++ show n] $ spec q
+  z <- getThisWeek
+  t <- getPrevWeek
+  return $ makeTable ["Subject","Last week","This week"] $ spec1 z t
 
 
-spec :: [[String]] -> [[String]]
-spec (x:y:z) = if head x ==  head y
-                  then [[head x] ++ tail x ++ tail y] ++ spec (y:z)
-                       else spec (y:z)
-                            
-spec (x:y:[]) = if head x ==  (head y)
-                  then [[head x], tail x ++ (tail y)] ++ spec [y]
-                       else spec [y]
 
-spec (x:[]) = [x]
-spec [] = []
+spec1 x y = merge1 (fst main) (snd main)
+  where set = nub $ map (\x -> x !! 0) $ x ++ y
+        elem1 x y= any (\z -> z !! 0 == x) y
+        diff1 = map (\q -> elem1 q x) set
+        diff2 = map (\q -> elem1 q y) set
+        set1  = zipWithPadding " " [" "] set x
+        set2  = zipWithPadding " " [" "] set y
+        main = (map (\q -> z (fst q) (snd q) ) $ zip  diff1 set1,
+             map (\q -> z (fst q) (snd q) ) $ zip  diff2 set2)
+
+z :: Bool -> (String,[String]) -> [String]      
+z x y  = if x then snd y else [fst y,"0"]
+
+zipWithPadding :: a -> b -> [a] -> [b] -> [(a,b)]
+zipWithPadding a b (x:xs) (y:ys) = (x,y) : zipWithPadding a b xs ys
+zipWithPadding a _ []     ys     = zip (repeat a) ys
+zipWithPadding _ b xs     []     = zip xs (repeat b)
+-- [True,False,False]
+-- [("cat",["cat","3"]),("cock",[" "]),("dog",[" "])]
+
+merge1 :: [a] -> [a] -> [a]
+merge1 xs     []     = xs
+merge1 []     ys     = ys
+merge1 (x:xs) (y:ys) = x : y : merge xs ys
+
diff --git a/src/Villefort/Database.hs b/src/Villefort/Database.hs
--- a/src/Villefort/Database.hs
+++ b/src/Villefort/Database.hs
@@ -111,6 +111,7 @@
 getSubWeek :: (MonadReader VConfig m, MonadIO m) => String -> String -> m [[String]]
 getSubWeek start end= makeQuery $  "select subject,sum(time) \
                       \  from todo where \
-                      \  substr(entered,1,10) >= '" ++  start ++"' \
-                      \and substr(entered,1,10)  <=  '"++ end ++ "' \
+                      \  substr(Due,1,10) >= '" ++  start ++"' \
+                      \and substr(Due,1,10)  <=  '"++ end ++ "' \
+                      \and time !=0 \
                       \group by subject "
diff --git a/src/Villefort/Time.hs b/src/Villefort/Time.hs
--- a/src/Villefort/Time.hs
+++ b/src/Villefort/Time.hs
@@ -55,14 +55,14 @@
 getDatesOfPrevWeek = do
   start <- addDays (-6) <$> getStartOfWeek
   currentDay <- getDay
-  return $ [start ,last $ take (currentDay+2) $ scanl next start [1,1 .. ]]
+  return $ [start ,last $ take (currentDay+1) $ scanl next start [1,1 .. ]]
   where next s   x = addDays (x) s
 
 getDatesOfThisWeek :: IO [Day]
 getDatesOfThisWeek = do
   start <- addDays (1) <$> getStartOfWeek
   currentDay <- getDay
-  return $ [start ,last $ take (currentDay+2) $ scanl next start [1,1 .. ]]
+  return $ [start ,last $ take (currentDay+1) $ scanl next start [1,1 .. ]]
   where next s   x = addDays (x) s
 
 
