Worked out a bug here and there