commented out debug code and added more comments on function roles