moved ajax actions to individual functions