refactored and added attack method and tests