starting work on optimization loops