Pulled out functions into util file