Implements the applying-function