updated for loops to foreach, fixed regex and parens