tweaked stackoverflow fix