move date function out