fix bug - nullpointer, need to check if the return is null