merge with Kylie's code