Improved previous optimization fix