neaten up the ray shooting code