cleaned up main controller