added null check for space left value