starting to simplify some loops