re-structured code using namespace and prototype.