moved function to a utiliy file