refactored datepicker.js