Updated to remove buggy code