Refactor datepicker

Proper datepicker code