rewrite to use arrays by soupmagnet