pat-1004

to be finished in main.cpp