calculate space in more cases