This causes mem leak. Why not just return an integer?