fixed ugly code