Turned attack into function