fixing compiler error due to bad static cast