moved utiltiy function