Updated script to handle better parsing