Mia's working version - very messy, needs to be cleaned up