even better code than before