fixed a bug (null check)