Added sphere intersection code