Working, but dirty code