Refactory with new API