add cast for type incompatibility. #1 fixed