merge with ashchan's changes