merged with kevin's code