Complete/functional code - modularized