simplify the code by using a little utility function