common js fucntion