Using parseInt(x, 10) instead of custom method