Memory is linked to exercise in new study