Fixed NullPointerException bug