Sort by date + refactor