better way of dealing with ray boundry problem, i hope