Refactoring selectedDate, removing unnecessary conversion from date to datekey