Changed code slightly