fix bugs in dimension calculations