Check NPE

Don't know why this happens but let's hope it will work.