pass scope into custom javascript functions