more correct with less code