Fix calendar function