updated with code for final manuscript