add function by direction