fixed a bug in unit cell calculation