Fixed a bug in the attack function caused by an API change