Refactor projectile code