variable rename and condition tweak in Melody::train