merged @jagodwin's changes