fixed so that casting would work correctly