fix bug in process; add debugging code to main