improved calender function