use correct key in joins
joining same table twice seems to be working, needs cleanup