fixing join statements