take key column from last column of input
removed testing on prepare_input function