wokred on substitution (partially working but ugly)