Refactor calendar