optimise: only lookup the ptr if preconditions pass