writing some convoluted code