adding nick's code