Made date range function work