fix bug--should not pop the data out if it is empty