implemented dates and fixed some algorithm gugs