adding jquery function wrapper and set some initial variables