updated code to reflect api changes