Trying to consolidate all logic in 1 script, non working version