fixing inefficient use of hashmap to store rays