updated to deal more accurately with different dimords
updated to deal more accurately with diff types of dimords