Moved helper function into separate files