Added ttwj's code (if it fixed anything?)