implemented refraction