Refactored code to avoid passing null as a texture