critical bug fixing

fixing bug with null when list is empty