Fixing Null Pointer Exception error