fix faulty casting