Copied implementation.