Fixed null exception bug