version that works but isn't pretty