extracted freebase functionality to separate javascript