tweaked and cleaned