fix plant add/update and split out code