refact and improve