Reformetted code
Added ajax methods