refactor ray tracer