improve trainsom funtion signature