Fixed Nullpointer bug