added ray checking for level 4 and 5