Fix issue where 2 ajax calls where being made