implemented ray test