Now uses proper SQL joining instead of incredibly hacky ways around having to access two tables