move key processing logic into their own methods for reuseability