despaghettified mike's code