simplified precondition check to cast functions