cleaned up main a bit