Updated code to new protocol