fixes bug in ajax call