add attack and several improvements to the code