more elegant solution for spaces