modified as per Josh's recommendations