refact code, separate compute firstDate and lastDate to a method