Fixed error with NullPointerException