merged with sam's changes