Refactor/simplify program