refactor obj function to a separate file