put javascript functions at top