Code written by Yiping and Hilary for Rotation with Joao Xavier