fixed casting bug and log