rolled up the unrolled loop to a simpler for loop
beginning to add support for flags
tested support of domain input