Eliminating duplicate code

Change-Id: Iab5ab6d4c6cd49777058dbd70554ae68b222e8b4
added jquery reference

Change-Id: I93981ab2f73b11ad459041c238f099956aae0198
fixed possible null pointer error

Change-Id: Iccfa09bf3c9e1f3cd912d36598bca03401123117