Fixed crash and add extra handling