cleaned code up so it is easily appied to other troops