rewrite functions for calculating first days