add with-keys macro

This is the latest code with the macro, I'll add the tests later but I thought atleast we should have this instead of the old code.