refactored algorithm, working now, back to calendar