Changed code sightly