fixed a bug of location may cause to segment fault.