Fixed null-pointer exception bug