code made less ugly