much more efficient code than before