updated security code a bug occurs where the code runs in an infinite loop - still investigating.