In the weighted logrank test such as Harrington-Fleming test and the Tarone-Ware test, predetermied weights are used to put more weight on early, middle or late events. The purpose is to maximize the power of the test. The optimal weights, which was derived in Gill (1980), depend on the true hazard functions of the groups being compared, and thus cannot be applied directly. We propose replacing the true hazard functions with their estimates and then using the estimated weights in a weighted logrank test. However, the resulting test doesn't control type I error correctly because the weights converge to 0 under the null in large samples. We then adjust the estimated optimal weights for correct type I error control while the resulting test still achieves improved power compared to existing weighted logrank tests. Simulation is carried out to assess the proposed method and it is applied in a real clinical study.