Logic implementation.