changed some things as per conversation with peter. still need to comment and make pretty