added javascript version using jquery