Replace deprecated APIs with newer one