updated with Tommy's changes