some strangeness/naming cleaned up and key repetition reduced with a new fn