fresnel reflection, refactored code