Simplified functions and added function for collecting stats