refact thanks to Adam