better error handling on k means cluster