simplify the code abit