fixing an NPE that I'm experiencing that I dont quite understand how its happening