Fixed possible bug that would have thrown a Null Pointer Exception