Second attempt. Let's actually read the code next time, chances are someone else already invented that wheel.