fixed casting issues