slightly more elegant code