Updated code to not use deprecated methods