This is the updated, working version