went back to plex global functions

Fix error in global plex function 
lot of fixes
first useble version