cleaned up main