moving function to utils