Refactored attack code