Added kinnes' code