Code Refactor to_key

I think we can do in single statement