IDEX-811; IDEX-706: refactor code