implement the filtering by period
fixing errors
refactoring switch sentence
latest changes from upstream
Resolving conflicts