Changed all functions to return objects