Cleaned up cpu function