main.cpp updated with input handling