Completed refactoring ; and added output of fields