simplified main() a bit