implementation of rays