add some more elegant code