cleaned up datepicker logic