Code for the Magic Staff project