updated to latest js api and jquery