Exported to utils.py. Before threading