Simplify datepicker code