Replace deprecated APIs with newer APIs