reverted "removed unneccessary code" - turns out that code wasn't unneccessary