fixed bug in ajax handler that caused infinite loop