functions, minimal for loops, assignment now working properly