modified and overhauled code to fit textureManager