improve the implementation