Fix submission code to get correct key, value and work with py3