more elegant solution