cleaned up __MAIN__ code