Prevent out of index exception
TODO:need better exception handler to handle it