added better functionality with jquery. it stil makes too many requests