some messy pointer arithmetic that doesn't work