adding an attack function and test