An Imitation Mechanism for Goal-Directed Actions