change elem to use foldl. much more concise. aw yeah.