basic implementation of join