Rewrite, remove looping, add optional vars object