fixed bug with incorrect calculation of dimensions