simplified main by inlining