refactored main program and updated docs with test procedure