some optimizations for ajax