added Nik's code