more elegant code