add key-value pair method to improve code