fixed faulty casting